@extends('company.company')

@section('title','企业中心')

@section('rightcontainer')
@include('front.common.editor')
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak={{$baidukey}}"></script>
<div class="col-xs-10" style="padding-right: 0;">
    {{-- 企业信息 block --}}
    @if($type == 'default')
    @include('company.basicinfo')
    @elseif($type == 'financing')
    {{-- 融资信息 block --}}
    @include('company.financing')
    @elseif($type == 'welfaretag')
    {{-- 福利标签 block --}}
    @include('company.infotags')
    @elseif($type == 'introduce')
    {{-- 产品介绍 --}}
    <div id="introduce" class="bord-1 font-16 backgr-color-white @if($type == 'introduce') show @else hidden @endif ">
        <div class=" clearfix boderbottom">
            <div class="color-1 padd-15 fl">公司产品</div>
        </div>
        @if($userinfo->company_id >0)
        <div class="center-block text-align-center company-form">
            <span class="color-4">简介有趣的产品介绍，能让应聘者以最快的速度了解公司业务。</span>
            <div class="add-product">
                <img class="cursor-pointer" src="{{ asset('/images/front/enterprise/add_tag_big.png') }}" width="50" height="50">
                <span class="font-24 color-1 padd-l-40">添加公司产品</span>
            </div>
        </div>
       @else
       <div class="no-company-show">
            请先完善企业基本信息，谢谢！
       </div>
       @endif
    </div>
    @elseif($type == 'features')
    {{-- 企业风采 --}}
    <div id="features" class="bord-1 font-16 backgr-color-white @if($type == 'features') show @else hidden @endif ">
        <div class="min-height-50 boderbottom clearfix">
            <div class="color-1 padd-15 fl">企业风采</div>
           {{-- <div class="add fr padd-15" onclick="showCompanyimgs()">
                <img src="{{ asset('/images/front/enterprise/add_tag.png') }}" width="24" height="24">
                <span class="color-1 padd-l-5 cursor-pointer"><strong>编辑</strong></span>
            </div>--}}
        </div>
        @if($userinfo->company_id >0)
        <div class="center-block text-align-center company-form">
            <form action="#" class="form-horizontal">
                <div class="feat-left fl width-per-100">
                    <div class="feat-left-1 upload-cover-img-box" id="upload-cover-img-box" style="width: 200px; height: 112px">
                         <span>效果预览</span>
                    </div>
                    <div class="feat-left-2">
                        <input type="file" id="upload_company_img" multiple="true">
                        <div id="some_file_queue" style="display: none"></div>
                    </div>
                    <div class="feat-left-3">
                        <span class="center-block">上传公司图片每张请小于300k</span>
                        <span class="center-block">尺寸：480px*266px(可上传30张)</span>
                    </div>
                </div>

                <div class="clr"></div>
                <div class="form-group padd-t-50">
                    <div id="jobs-hots-more" class="margin-25-0 ">
                        <button type="button" id="getMoreJobs" class="btn-ok">发布</button>
                        <button type="button" id="getMoreJobs" class="btn-cance">取消</button>
                    </div>
                </div>
            </form>
        </div>
        <div id="companyimgs">
          <div class="upload-img-box">
           @foreach ($photos as $key=>$photo)
            <div id="{{$photo->image_id}}" class='divImg'>
                <a href="javascript:void(0)" class="span_close ">×</a>
                <img src='{{$photo->path}}' width="200" height="112" >
                <input type='hidden' name='imageid' value='{{$photo->image_id}}'>
            </div>
            @endforeach
          </div>
        </div>
        @else
       <div class="no-company-show">
            请先完善企业基本信息，谢谢！
       </div>
       @endif
        <div class="clr"></div>
    </div>
    @elseif($type == 'reports')
    {{-- 相关报道 --}}
    <div id="reports" class="bord-1 font-16 backgr-color-white @if($type == 'reports') show @else hidden @endif ">
        <div class="min-height-70 clearfix boderbottom">
            <div class="color-1 padd-15 fl">相关报道</div>
        </div>
        <div class="form" style="width:440px;margin: 30px auto;">
            <form class="form-inline">
              <div class="form-group">
                <label class="col-sm-2 control-label form-label">报道标题：</label>
                <input type="email" class="form-control" id="inputEmail3" placeholder="报道标题">
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label form-label">报道链接：</label>
                <input type="email" class="form-control" id="inputEmail3" placeholder="http://">
              </div>
              <div id="jobs-hots-more" class="padd-t-30 ">
                  <button type="button" id="getMoreJobs" class="btn-ok">发布</button>
                  <button type="button" id="getMoreJobs" class="btn-cance">取消</button>
              </div>
            </form>
        </div>
    </div>
    @endif
</div>
<script type="text/javascript">
// 风采上传
$(function() {
    bingimg();
    $("#upload_company_img").uploadify({
        'formData'     : {
            'fileField':'upfile',
            '_token':'{{ csrf_token() }}',
            'company_id':'{{empty($mycompany)?0:$mycompany->id}}'
        },
        "width"           : 120,
        "height"          : 30,
        'removeCompleted' : true,
        'queueID'         : 'some_file_queue',
        "swf"             : "{{ asset('/js/uploadify/uploadify.swf') }}",
        "fileObjName"     : "upfile",
        "buttonText"      : "",
        "buttonClass"     : "uploadify-button",
        "uploader"        : "/upload/comimg",
        'removeTimeout'	  : 1,
        'auto'			  : true,
        'fileTypeExts'	  : '*.gif; *.jpg; *.jpeg; *.png;',
        'fileSizeLimit'	  : '1024KB',
        'onUploadStart' :function(){
            var num=$('.upload-img-box').children('.divImg').length;
             if(num>=30){
              layer.open({
                     title: '提示',
                     content: '您已经上传了30张图片，您可以删除现有的图片再进行上传'
              });
             $('#upload_img').uploadify('cancel');
             $('#upload_img-queue').empty();
             return false;
             }
        },
        'onUploadSuccess':function(file, data, response){
            var data = eval('(' + data + ')');
            if (data.status == 'success') {
                var html="<img src='"+data.attach+"' width='200' height='112'>" +
                    "<input type='hidden' id='newimg' value='"+data.attach_id+"'>"
                $('.upload-cover-img-box').html(html);
            }else{
                alert(data.state);
                return false;
            }
        }
    });

    $('.btn-ok').click(function(){
        var imageid=$('#newimg').val();
        var attach= $("#upload-cover-img-box img").attr("src");
        var html ='<div id='+imageid+' class="divImg">'
                   +'<a href="javascript:void(0)" class="span_close">×</a>'
                   +'<img src="'+attach+'"  width="200" height="112">'
                   +'<input type="hidden" name="imageid" value="'+imageid+'">'
                 +'</div>';
        if(imageid>0){
            $('.upload-img-box').prepend(html);
            bingimg();
        }
        $('.upload-cover-img-box').html('<span>效果预览</span>');
    });
    $('.btn-cance').click(function(){
        var imageid=$('#newimg').val();
        delimg(imageid,'{{csrf_token()}}');
        $('.upload-cover-img-box').html('<span>效果预览</span>');
    });
    // 头部菜单导航样式
    $('#job_nature li').each(function(i,e){
        $(e).click(function(){
            $('#job_nature').find('.color-white').attr('class', 'backgr-color-main margin-l-15');
            $(this).attr('class', 'color-white backgr-color-4');
        });
    });

    // 自定义添加标签
    $('#add_tag').click(function(){
        var tag_name = $('#custom_tag').val();
        var html = '<li class="fl">'
        		+ '<small>'+tag_name+'</small>'
        		+ '<span  onclick="del_tag(this)" class="glyphicon glyphicon-remove tag-remove"></span>'
        		+'<input type="hidden" name="tags[]" value="'+tag_name+'">'
        		+'</li>';
        $('#had_tag').append(html);

    });

    $('#select_tag ul li').click(function(){
        var selected = $(this).attr('data');
        var tag_name = $(this).text();
        if(selected === undefined){
            $(this).attr('class', 'backgr-color-5').attr('data', 'selected');
            var html = '<li class="fl">'
        		+ '<small>'+tag_name+'</small>'
        		+ '<span  onclick="del_tag(this)" class="glyphicon glyphicon-remove tag-remove"></span>'
        		+'<input type="hidden" name="tags[]" value="'+tag_name+'">'
        		+'</li>';
            $('#had_tag').append(html);
        }else{
            $(this).attr('class', 'backgr-color-ccc').removeAttr('data');
        }
    });
    $("#checkUname").bind('input propertychange',function(){
    	var uname = $(this).val();
    	checkCompany('/company/center/company/check?name='+uname,'error');
    })
});

$('input').iCheck({
	checkboxClass: 'icheckbox_flat-blue',
    radioClass: 'iradio_flat-blue',
    increaseArea: '-10' // optional
});
var editor;
KindEditor.ready(function(K) {
	editor = K.create('.content', {	
    	resizeType : 1,
    	//allowPreviewEmoticons : false,
    	afterBlur: function () { this.sync(); },
    	allowImageUpload : true,
    	width : "100%", 
    	allowUpload : true,
    	//postParams:123,
    	//uploadJson : '/index.php?g=User&m=Upyun&a=kindedtiropic',
    	items : ["justifyleft", "justifycenter", "justifyright", ]
	});

});

function bingimg(){
    //图片绑定事件
    $('.divImg').on("mouseover",function(){
        $(this).children('.span_close').show();
    });
    $('.divImg').on("mouseout",function(){
        $(this).children('.span_close').hide();
    });
    $('.span_close').on('click',function(){
        var imageid=$(this).parent().children('input[type=hidden]').val();
        delimg(imageid,'{{csrf_token()}}');
    });
}
function delimg(imageid,token){
     $.ajax({
        type:"POST",
        url:'/company/center/company/del',
        data:'imageid=' + imageid +'&_token='+token,
        success:function (data) {
                if(data.status == 'success'){
                    $("#"+imageid).remove();
                }
            }
     });
 }

function showCompanyimgs(){
    layer.open({
        type: 1,
        area: ['935px', '500px'],
        title:['企业风采', 'font-size:18px;'],
        skin: 'layui-layer-rim',
        content: $('#companyimgs')
    });
}
</script>

@stop

@section('footer')
@parent
@stop

